﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PhotoBook
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class WindowPrincipal : Window
    {
        public WindowPrincipal()
        {
            InitializeComponent();
        }
        
        private void Button1_Click(System.Object sender, System.Windows.RoutedEventArgs e)
        {
            Model.Entities.FotoTransformation fotoTransformation = new Model.Entities.FotoTransformation();
            fotoTransformation.IndexFoto = 1;
            fotoTransformation.NomeFoto = "Foto de teste";
            fotoTransformation.Transformacao = ImagemManipular.RenderTransform.Value;
            fotoTransformation.Origem = ImagemManipular.RenderTransformOrigin;

            PhotoBook.Model.Services.IStore storeImage = new PhotoBook.Services.StoreTransformation();
            storeImage.SaveTransformationToFile(fotoTransformation, "C:\\Fotos\\Teste.bnf");
            
            PhotoBook.Model.Services.IStore storeImageXml = new PhotoBook.Services.StoreXmlTransformation();
            storeImageXml.SaveTransformationToFile(fotoTransformation, "C:\\Fotos\\Teste.xml");
        }

        private void Button2_Click(System.Object sender, System.Windows.RoutedEventArgs e)
        {
            PhotoBook.Model.Services.IOpenStored openStoredTransformation = new Services.OpenStoredTransformation();
            var fotoTransformation = openStoredTransformation.OpenTransformation("C:\\Fotos\\Teste.bnf");

            ImagemManipular.RenderTransformOrigin = fotoTransformation.Origem;
            ImagemManipular.RenderTransform = new MatrixTransform(fotoTransformation.Transformacao);
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            CadastroCategoria categoria = new CadastroCategoria(new Repositorio.RepositorioCategoria());
            categoria.ShowDialog();
        }

        private void MenuAlbum_Click(object sender, RoutedEventArgs e)
        {
            CadastroAlbum album = new CadastroAlbum(new Repositorio.RepositorioAlbum(), new PhotoBook.Repositorio.RepositorioCategoria() );
            album.ShowDialog();
        }

        private void MenuTemplates_Click(object sender, RoutedEventArgs e)
        {
            CadastroTemplate template = new CadastroTemplate();
            template.ShowDialog();
        }

        private void MenuProximo_Click(object sender, RoutedEventArgs e)
        {
            CriarTemplate template = new CriarTemplate(this);
            template.Show();
            this.Hide();
        }
    }
}
